<script setup lang="ts">
import { ref } from "vue";
import ReCol from "@/components/ReCol";
import { formRules } from "./utils/rule";
import { FormProps, usePublicHooks } from "@/views/hooks";
import { Job } from "@/api/job";

const props = withDefaults(defineProps<FormProps<Job>>(), {
  formInline: () => ({
    id: "",
    name: "",
    description: "",
    status: true
  })
});
const ruleFormRef = ref();
const { switchStyle } = usePublicHooks();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-row :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="职务名称" prop="name">
          <el-input
            v-model="newFormInline.name"
            clearable
            placeholder="请输入职务名称"
          />
        </el-form-item>
      </re-col>
      <re-col>
        <el-form-item label="职务描述" prop="description">
          <el-input
            v-model="newFormInline.description"
            clearable
            placeholder="请输入职务描述"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="职务状态">
          <el-switch
            v-model="newFormInline.status"
            inline-prompt
            :active-value="true"
            :inactive-value="false"
            active-text="启用"
            inactive-text="停用"
            :style="switchStyle"
          />
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>
</template>
